package cn.com.JdbcFoundation;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCDemo {

    public static void main(String[] args) throws Exception{

        //注册驱动
//        Class.forName("com.mysql.jdbc.Driver");

        //获取本地连接
        String url = "jdbc:mysql://127.0.0.1:3306/ssm_db?serverTimezone=Asia/Shanghai";
        String username = "root";
        String password = "324400";

        Connection con = DriverManager.getConnection(url,username,password);

        //获取sql
        String sql = "select * from play_log";

        //获取执行sql的对象statement
        Statement stat = con.createStatement();
        ResultSet rs = stat.executeQuery(sql);
        while (rs.next()){
            String song_id = rs.getString("song_id");
            String user_id = rs.getString("user_id");
            String fdate = rs.getString("fdate");

            System.out.println(song_id);
            System.out.println(user_id);
            System.out.println(fdate);
        }


    }
}
